package org.halk.service;

import org.halk.service.impl.StrategyHorServiceImpl;
import org.halk.service.impl.StrategyTestServiceImpl;
import org.halk.service.impl.StrategyVerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class StrategyFactory {

    private final ApplicationContext context;

    @Autowired
    public StrategyFactory(ApplicationContext context) {
        this.context = context;
    }

    public StrategyService getService(String projectId) {
        switch (projectId.toUpperCase()) {
            case "HOR":
                return context.getBean("strategyHorServiceImpl", StrategyHorServiceImpl.class);
            case "VER":
                return context.getBean("strategyVerServiceImpl", StrategyVerServiceImpl.class);
            case "TEST":
                return context.getBean("strategyTestServiceImpl", StrategyTestServiceImpl.class);
            default:
                return context.getBean("strategyHorServiceImpl", StrategyHorServiceImpl.class);
        }
    }
}
